﻿Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.IO

Public Class settings
    Public Mainform As Form1
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK

        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub settings_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DocumentManagementDataSet.dept' table. You can move, or remove it, as needed.
        Me.DeptTableAdapter.Fill(Me.DocumentManagementDataSet.dept)
        'TODO: This line of code loads data into the 'DocumentManagementDataSet.company' table. You can move, or remove it, as needed.
        Me.CompanyTableAdapter.Fill(Me.DocumentManagementDataSet.company)
        lblversion.Text = Me.ProductVersion
        Mainform.settingsdialog.txtroot.Text = My.Settings.rootdir
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'Dim con As New SqlConnection
        Dim con As New Odbc.OdbcConnection

        'Dim MyConString As String = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=192.168.1.19; DATABASE=documentmanagementwamp; UID=SERGENTLOIS; PASSWORD=1;"
        'LOCAL Data Source=LOIS-PC\SQLEXPRESS;Initial Catalog=DocumentManagement;Integrated Security=True

        Try
            con.ConnectionString = txtconstr.Text
            'con.ConnectionString = MyConString
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


        Try
            con.Open()
            MsgBox("Test Connection Success!", MsgBoxStyle.Information)
            con.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub settings_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        My.Settings.rootdir = txtroot.Text
        My.Settings.Save()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If Directory.Exists(txtroot.Text) Then
            MsgBox("Directory Exist", MsgBoxStyle.Information)
        Else
            MsgBox("Directory Doesn't Exist", MsgBoxStyle.Information)
        End If
    End Sub
End Class
